<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
	<%@page import="Logic.Authorizer"%>
	<%@ page import="java.sql.*" %>
	<%@ page import="java.io.*" %> 
	<%@page import="servlet.DeviationNotesDropDown"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	if (session.getAttribute("name") == null) {
		response.sendRedirect("login.jsp");
	} else {
		if (!Authorizer.checkRole("2", session.getAttribute("role")
				.toString())) {
			response.sendRedirect("nopermission.jsp");
		}
	}
%>
<jsp:include page="t_header.jsp" />

<div class="breadcrumbs_container">
	<article class="breadcrumbs"> <a href="QM_NewDeviationNotes.jsp">Manage Quality
		Manual</a>
	<div class="breadcrumb_divider"></div>
	<a class="current">Delete Deviation Notes</a> 
	</article>
</div>
<jsp:include page="header.html" />

<!-- Declare sidebar -->
<jsp:include page="t_sidebartry.jsp" />

<!-- Main Content -->
<body>
	<section id="main" class="column">
	<article class="module width_3_quarter">
	<form id="DeleteForm" name="DeleteForm" onsubmit="CFMDelete();">
	<header><h3>Select a Note to delete</h3></header>
	<div class="module_content">
	<fieldset>
	<label>Deviation Note</label>
	<select name="DDN" id="DDN" style="width:80%">
						<%
							DeviationNotesDropDown DND = new DeviationNotesDropDown(out);
							DND.doGet(request, response);
						%>
	</select>
	</fieldset>
	</div>
	<footer>
	<div class="submit_link">
	<input id="Delete" name="Delete" type="submit" value="Delete" class="alt_btn"/>
	</div>
	</footer>
	<input id="answer" name="answer" type="hidden"/>
<%
	String answer = request.getParameter("answer");
  	 if(answer == null || "".equals(answer))answer = "false";
  	 	if("true".equals(answer)){
  	 		String deviationNoteTitle=request.getParameter("DDN");
  	 		int j1 = 0;
  	 		j1 = DND.deleteDeviationNotes(deviationNoteTitle);
  				if(j1>0) 
  	  			{ 				
  					System.out.println("Operation Completed Successfully! ");
  					  					%>
  					  					<script>
  					window.location="QM_Deviation_Notes.jsp";
  					  					</script>
  					<% 
  	  			}
  				}%>
    </form>
    </article>
<script type="text/javascript">
function CFMDelete(){
var TempVal=document.getElementById('DDN');
var selectedText = TempVal.options[TempVal.selectedIndex].text;
var answer = confirm ("Are you sure you want to continue deleting \n("+selectedText+")?");
  if (answer){
              document.DeleteForm.answer.value = "true";  
              document.DeleteForm.submit();
            
              return true;
    }else 
    alert("Please choose carefully before deleting! ");
    return false;

}
</script>
<div class="spacer"></div>
</section>
</body>



